package cc.ufinity.networkdiagnose.view;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import cc.ufinity.networkdiagnose.widget.SettingWidget;

public class CfgActivity extends AbstractActivity {
	private SettingWidget textView;
	private Handler mHandler;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mHandler = new Handler() {

			@Override
			public void handleMessage(Message msg) {
				switch (msg.what) {
				case 1:
					dismissExitDialog();
					exit();
					break;
				}
			}

		};
		textView = new SettingWidget(this);
		setContentView(textView);
	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {

		 if (keyCode == KeyEvent.KEYCODE_BACK){
			 if (SettingWidget.num == 2) {
					this.finish();
				} else {
					setContentView(textView);
					SettingWidget.num = 2;
					return true;
				}
		 }
		 
		
		/*if (SettingWidget.num == 2) {
			this.finish();
		} else if (keyCode == KeyEvent.KEYCODE_BACK) {
			setContentView(textView);
			SettingWidget.num = 2;
			return true;
		}*/ /*else if (keyCode == KeyEvent.KEYCODE_MENU) {
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.setTitle("提示");
			// builder.setIcon(R.drawable.what);
			builder.setMessage("确定退出系统吗？");
			builder.setCancelable(false);
			builder.setPositiveButton("确定",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
							webLogout(mHandler);
							dialog.dismiss();
							showExitDialog();
						}
					});
			builder.setNegativeButton("取消",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
							dialog.cancel();
						}
					});
			builder.show();
		}*/
		return false;
	}
}
